package main

import (
	"fmt"

	"gitee.com/yangwencheng/vblog/mvc/api"
	"github.com/fsnotify/fsnotify"
	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
)

func main() {
	viper.SetConfigName("config")
	viper.SetConfigType("json")
	viper.AddConfigPath("/home/ywc/workspace/yangwencheng/vblog/mvc/")

	err := viper.ReadInConfig() // 搜索并读取配置文件
	if err != nil {             // 处理错误
		panic(fmt.Errorf("Fatal error config file: %s \n", err))
	}
	viper.OnConfigChange(func(e fsnotify.Event) {
		fmt.Println("Config file changed:", e.Name)
	})
	viper.WatchConfig()
	fmt.Println("配置文件", viper.AllSettings())
	r := gin.Default()
	r.POST("/create/blog", api.HandelCreateBlog)
	r.Run() // 监听并在 0.0.0.0:8080 上启动服务
}
